package cn.edu.nju.software.action.comment;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.edu.nju.software.bean.show.UserShow;
import cn.edu.nju.software.service.intf.CommentService;
import cn.edu.nju.software.util.Constants;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class AddCommentAction extends ActionSupport implements SessionAware {
	
	private int bookID;
	private String comment;
	private CommentService commentService;
	private Map<String, Object> session;
	
	public void setBookID(int bookID) {
		this.bookID = bookID;
	}

	public int getBookID() {
		return bookID;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public void setCommentService(CommentService commentService) {
		this.commentService = commentService;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	@Override
	public String execute() throws Exception {
		UserShow user = (UserShow) session.get(Constants.SESSION_USER);
		commentService.postComment(user.getUserID(), bookID, comment);
		return SUCCESS;
	}

}
